class Solution {
public:
    vector<int> hash;
    void dfs(vector<vector<int>>& isConnected,int n,int u,int color)
    {
        if(hash[u])
            return;
        hash[u]=color;
        for(int i=0;i<n;i++)
        {
            if(isConnected[u][i])
            {
                dfs(isConnected,n,i,color);
            }
        }
    }
    int findCircleNum(vector<vector<int>>& isConnected) {
        hash.resize(210);
        int n=isConnected.size();
        int color=0;
        for(int i=0;i<n;i++)
        {
            if(!hash[i])
            {
                color++;
                dfs(isConnected,n,i,color);
            }
        }
        return color;
    }
};